package com.hyperboost.controller;

import com.hyperboost.dto.OpportunityPageQueryDTO;
import com.hyperboost.result.PageResult;
import com.hyperboost.result.Result;
import com.hyperboost.service.OpportunityService;
import com.hyperboost.vo.OpportunityVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 机会相关接口
 */
@RestController
@RequestMapping("/frontend/opportunity")
public class OpportunityController {

    @Autowired
    private OpportunityService opportunityService;

    /**
     * 分页条件查询所有机会
     *
     * @param opportunityPageQueryDto
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult<OpportunityVO>> page (OpportunityPageQueryDTO opportunityPageQueryDto){
        return Result.success(opportunityService.pageQuery(opportunityPageQueryDto));
    }

    /**
     * 查看机会详情
     *
     * @param opportunityId
     * @return
     */
    @GetMapping("/{opportunityId}")
    public Result<OpportunityVO> getOpportunityDetail(@PathVariable Long opportunityId) {
        return Result.success(opportunityService.getOpportunityDetail(opportunityId));
    }
}
